package com.china.produce.handler;

import cn.hutool.core.util.StrUtil;
import java.util.HashMap;
import java.util.Map;

/**
 * 工厂模式+策略模式
 *
 * @ClassName
 * @Author niujie
 * @Version
 * @Description
 * @CreateTime 2023/2/9
 */
public class Factory {

    private static Map<String, AbstractHandler> STRATEGY_MAP = new HashMap();

    public static void register(String name, AbstractHandler handler)
    {

        if (StrUtil.isEmpty(name) || handler == null) {

            return;
        }

        STRATEGY_MAP.put(name, handler);
    }

    public static AbstractHandler get(String name)
    {

        return STRATEGY_MAP.get(name);
    }
}
